
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/Modules/system/layuimini/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/Modules/system/layuimini/css/public.css" media="all">

    <link rel="stylesheet" href="/Modules/system/sys/css/index.css" media="all">

<style>
    .comp{
        background: red !important;
        color: #ffffff !important;
        border: none;
    }
</style>

</head>
<body>

<div class="layuimini-container">



    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">审核状态</label>
                            <div class="layui-input-inline">
                                <select data-search-type="=" name="status" lay-verify="required">
                                    <option value="-1">全部</option>
                                    <option value="0">审核中</option>
                                    <option value="1">已通过</option>
                                    <option value="2">已拒绝</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">文件主题</label>
                            <div class="layui-input-inline">
                                <input type="text" type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">文件类型</label>
                            <div class="layui-input-inline">
                                <input type="text" type="text" name="type" autocomplete="off" class="layui-input">
                            </div>
                        </div>



                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>

                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbar">
            <div class="layui-btn-container">

                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>

            </div>
        </script>


        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>


{{--        <script type="text/html" id="currentTableBar">--}}

{{--            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>--}}
{{--            <a style="margin-left: 0px;" class="layui-btn layui-btn-normal layui-btn-xs data-count-invalid invalid" lay-event="invalid">无效</a>--}}

{{--        </script>--}}

    </div>

</div>

<script src="/Modules/system/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>



<script>

    //扩展执行js
    function self_extend(obj,layui){
        $ = layui.jQuery, table = layui.table, allJs = layui.allJs, data = obj.data;
        if(obj.event == 'personnel'){

        }
        if(obj.event == 'invalid'){
            //询问框
            layer.confirm('确定要对本单位设置无效？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                //layer.msg('的确很重要', {icon: 1});

                layer.msg('暂时不更改数据', {icon: 1});

            }, function(){

            });
        }

    }

</script>


<script>

    //获取目录
    window.rootPath = (function (src) {
        src = document.scripts[document.scripts.length - 1].src;
        return src.substring(0, src.lastIndexOf("/") + 1);
    })();

    layui.config({
        base: rootPath + "/Modules/system/layuimini/js/lay-module/",
        version: true
    }).extend({
        arrayJs: "chinadmin/arrayJs",
        chinAdmin: "chinadmin/chinAdmin",
    });

    layui.use(['form', 'table','laydate','arrayJs','chinAdmin'], function () {

        var $ = layui.jquery, form = layui.form, table = layui.table,laydate = layui.laydate,chinAdmin = layui.chinAdmin;

        //头部搜索初始化组件

        //所有的项配置
        var $cols = [
            {type: "checkbox", width: 50},
            //逐步放弃这种扩展方式，采用头部<script type="text/html" id="currentTableBar">块扩展
            {title: '操作', minWidth: 170,  templet: function(d){


                    if(d.status==0){


                        return   '<a class="layui-btn layui-btn-primary layui-btn-xs comp" lay-event="comp">审核</a>' +
                            '<a class="layui-btn layui-btn-xs" lay-event="comp1">查看</a>' +
                            '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>'
                    }else  if(d.status==1){
                        $('.dijia').hide()
                            return  '<a class="layui-btn layui-btn-xs" lay-event="comp1">查看</a>' +
                            '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>'

                    }else if(d.status==2){
                        state=1
                        return '<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>' +
                            '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>'
                    }

                }},

            {field: 'id', width: '80', title: 'id',sort: parseInt('0'),templet: function(d){
                    return d.id?d.id:'';
                }},
            {field: 'company_id', width: '200', title: '所属公司',sort: parseInt('0'),templet: function(d){
                    //选择##防止没有报错
                    if(typeof(d.p_company) == "undefined" || d.p_company == null){
                        return "";
                    }else{
                        return d.p_company.company_name;
                    }
                }},
            {field: 'name', width: '150', title: '文件主题',sort: parseInt('0'),templet: function(d){
                    return d.name?d.name:'';
                }},
            {field: 'type', width: '150', title: '文件类型',sort: parseInt('0'),templet: function(d){
                    return d.type?d.type:'';
                }},
            {field: 'con', width: '150', title: '文件内容',sort: parseInt('0'),templet: function(d){
                    return d.con?d.con:'';
                }},
            {field: 'department_id', width: '150', title: '发文部门',sort: parseInt('0'),templet: function(d){
                    //选择##防止没有报错
                    if(typeof(d.p_department) == "undefined" || d.p_department == null){
                        return "";
                    }else{
                        return d.p_department.name;
                    }
                }},
            {field: 'status', width: '150', title: '审核状态',sort: parseInt('0'),templet: function(d){
                    //选择##防止没有报错
                    if(d.status==0){
                      return '<button type="button" class="layui-btn layui-btn-xs">审核中</button>'
                    }
                    if(d.status==1){
                        return '<button type="button" class="layui-btn layui-btn-xs">审核通过</button>'
                    }
                    if(d.status==2){
                        return '<button type="button" class="layui-btn layui-btn-xs">审核拒绝</button>'
                    }
                }},

        ];

        //son子模板$cols扩展编辑项
        typeof self_extend_cols === "function" ? ($cols = self_extend_cols($cols,layui)) : false;

        //初始化表格,为每一个赋值。
        table.render({
            elem: '#currentTableId',
            url: "/chinadmin/admin/FileData/index?",
            toolbar: '#toolbar',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '列表',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [$cols],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            skin: 'line',
            done:function (e) {
                if(e.code == 400){
                    layer.msg(e.msg);
                }
            }
        });

        //通用调用
        layui.$class = 'FileData';
        layui.$this_id = 'id';
        layui.$table = 'ca_file_data';
        chinAdmin.index(layui);
        //编辑删除操作
        table.on('tool(currentTableFilter)', function (obj) {

            var data = obj.data;

            typeof self_extend === "function" ? self_extend(obj,layui) : false;
             if(obj.event === 'comp'){
                var index = layer.open({
                    title: '审核',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: "/chinadmin/admin/FileData/examine?id="+data.id+'',
                });
            } else if(obj.event === 'comp1'){
                 var index = layer.open({
                     title: '查看',
                     type: 2,
                     shade: 0.2,
                     maxmin:true,
                     shadeClose: true,
                     area: ['100%', '100%'],
                     content: "/chinadmin/admin/FileData/examine?id="+data.id+'&hide=1',
                 });
             }

        });
    });
</script>

</body>
</html>